import React, { Component } from 'react'
import { Button, Modal, } from 'antd';
import InfoForm from "./InfoForm"

export default class CreateForm extends Component {
    constructor(props) {
        super(props)

        this.state = {
            visible: true,
        }
    }
    //接受子组件的提交
    sendSubmit(submit) {
        this.setState({
            submit,
        })
    }
    renderFooter() {
        return (
            <>
                <Button onClick={() => this.props.onCancel()}>取消</Button>
                <Button type="primary" onClick={() => {
                    //接受子组件的提交
                    this.state.submit();
                }}>
                    完成
            </Button>
            </>
        )
    }
    render() {
        return (
            <Modal
                style={{
                    top: "24px",
                    minWidth: "900px",
                    maxWidth: "1200px",
                }}
                width={"80%"}
                title="添加"
                visible={this.props.createModalVisible}
                destroyOnClose={true}
                maskClosable={false}
                footer={this.renderFooter()}
                onCancel={() => this.props.onCancel()}
            >
                <InfoForm onFinish={(fieldsValues) => {
                    this.props.onSubmit(fieldsValues)
                    // console.log("obj", obj)
                }} sendSubmit={this.sendSubmit.bind(this)} />
            </Modal>
        )
    }
}
